<template>
	<view>
		<loading :is_init="is_init" :show_time="300"></loading>
		<!-- #ifdef APP -->
		<view class="" style="height: 120rpx;">
		</view>
		<!-- #endif -->
		<view class=" " style="height: 250rpx;">
			<view @click="on_url('../../pages/banmi/user_set',1)" class="flex j-f pt2" style="padding-right: 60rpx;">
				<text class="bicon f60">&#xe7f9;</text>
			</view>
			<view class="flex a-c j-b" style="padding-top: 10rpx;padding-right: 60rpx;padding-left: 60rpx;">
				<view class="flex a-c" @click="on_url('../../pages/banmi/user_set',1)">
					<view class="">
						<image class="q_y face" :src="user.face|getFace">
						</image>
					</view>
					<view class="ml20">
						<text class="w800 f36">{{user.nickname?user.nickname:'请登陆！'}}</text>
					</view>
				</view>
				<view @click="on_url('../../pages/banmi/addr_list',1)" class="button_bg flex j-c a-c by1"
					style="width: 190rpx;height: 50rpx;">
					<text class="bicon  f26">&#xe651;</text>
					<text class="ml1 f30">收货地址</text>
				</view>
			</view>
		</view>

		<view class="p2" style="padding-right: 30rpx;padding-left: 30rpx;">
			<view class="p20 b_y" style="margin-top: -20rpx;background-color: #fff;">
				<view class="pb3 flex j-b">
					<view class="f32">
						我的订单
					</view>
					<view class="c_7  " @click="on_url('../../pages/jianyueshop/order_list?id=0',1)">
						<text class="f26">全部订单</text>
					</view>
				</view>
				<view class="flex j-b a-c">


					<view class="t_c p1 pt2 pb2" @click="on_url(vo.url,vo.is_login)" v-for="(vo,index) in my_list1"
						:key="index" tyle="position: relative;">
						<view class="" style="position: relative;">
							<view class="t_c">

								<image style="width: 50rpx;height: 50rpx;" :src="vo.img|getImg" mode=""></image>
								<view class="c_z f28 f800 pt1">{{vo.name}}</view>
							</view>
							<view v-if="count_find[vo.count]>0" class=" flex a-c j-c cff q_y yuandian"
								style="right: -10rpx;">
								<text>{{count_find[vo.count]}}</text>
							</view>
						</view>
					</view>



				</view>
			</view>
		</view>

		<view class="p2" style="padding-right: 30rpx;padding-left: 30rpx;">
			<view class="p20 b_y" style="margin-top: -20rpx;background-color: #fff;">

				<view @click="on_url(vo.url,vo.is_login)" v-for="(vo,index) in my_list2" :key="index" class="p20"
					style="padding-top: 40rpx;padding-bottom: 40rpx;">
					<view class="flex j-b a-c">
						<view class="flex a-c" style="position: relative;">
							<view style="left:30rpx;" class=" flex a-c j-c cff q_y yuandian"
								v-if="count_find.type5_count>0&&vo.standby==1">
								<text>{{count_find.type5_count}}</text>
							</view>
							<image style="width: 50rpx;height: 50rpx;" :src="vo.img|getImg" mode="">
							</image>
							<text class="ml1">{{vo.name}}</text>
						</view>
						<view class="flex a-c">
							<text class="bicon c_7">&#xe6a3;</text>
						</view>
					</view>
				</view>



			</view>
		</view>

		<tabbar></tabbar>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: '',
				token: '',
				is_worker: false,
				worker_name: '师傅',
				count_find: {
					"type1_count": 0,
					"type2_count": 0,
					"type3_count": 0,
					"type4_count": 0,
					"type5_count": 0,
					"type7_count": 0,
					"type8_count": 0,
				},
				my_list1: [],
				my_list2: [],
				is_init: false

			}
		},

		onLoad() {

			var that = this;
			this.token = uni.getStorageSync('token');


			let requestParams = {};
			this.Http.post('/plugin.php/videoappdownload/api/Settings/index', requestParams).then(ret => {
				if (ret.status == 200) {
					var my_list1 = ret.data.set_find.my_list1;
					var my_list2 = ret.data.set_find.my_list2;
					this.my_list1 = my_list1;
					this.my_list2 = my_list2;
				}
			})



			this.init();

			uni.$on('banmi_login', function(data) {

				that.token = uni.getStorageSync('token');
				that.init();
			})
			if (this.token) {
				//监听头像修改
				uni.$on('banmi_face', function(data) {
					that.user.face = data.face
				})
				//监听昵称修改
				uni.$on('banmi_nickname', function(data) {
					that.user.nickname = data.nickname
				})

			}

		},
		onShow() {

		},
		methods: {
			subScribeMsg() { // 订阅信息
				uni.getSetting({
					withSubscriptions: true,
					success(res) {
						console.log('1', res.subscriptionsSetting);
						if (!res.subscriptionsSetting.mainSwitch) {
							uni.openSetting({ //打开设置页
								success(res) {
									console.log(res.authSetting);
								}
							})
						} else {
							uni.requestSubscribeMessage({
								tmplIds: ['I9zRogt26t8aRKR0hdlFdpAp6L6Y9R696Rn40n3755c',
									'uJDgqsFEDw2sO6-snNOBb-UPlZ4xIla7lewQ9bmP9UE',
								],
								success(res) {
									console.log(res);
									if (res['I9zRogt26t8aRKR0hdlFdpAp6L6Y9R696Rn40n3755c'] ==
										"accept") { // 用户点击确定后
										console.log('1111');
									}
								}
							})
						}
					}
				})
			},
			init() {
				if (!this.token) {
					this.is_init = true;
					this.token = uni.getStorageSync('token');
					this.user_id = uni.getStorageSync('user_id');
					this.user = '';

				}
				this.Banmikeji.user_info().then(ret => {
					if (ret != 0) {
						this.user = ret.data.user;
					}
					this.is_init = true;
				})
			},

			article_view(index) {

				uni.navigateTo({
					url: '/pages/banmi/article_view?id=' + index
				})
			},
			on_url(url, index) {

				if (index == 1) {
					if (!uni.getStorageSync('token')) {
						uni.navigateTo({
							url: '/pages/banmi/user_login'
						})
						return
					}
				}

				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style>
	.yuandian {
		position: absolute;
		width: 40rpx;
		height: 40rpx;
		background-color: #FA4123;
		top: -15rpx;
		right: 5px;
		font-size: 24rpx;
	}
</style>